<template>
  <div>

                        
                        <div class="article toolbar">
                        
                            <div class="container" style="padding-bottom:50px;">

                                <div class="title ue-clear">
                                    <h2>聊天文件更新</h2>
    
                                </div>
                                <form method="POST" action="javascript:;">

                                    <div class="main" style="width: 50%;">

                                        <div class="short-input ue-clear">
                                            <label>发送人：</label>
                                            <input v-model="form.fromid" class="form-control" name="fromid" required value="" type="text" placeholder="">
                                            <span></span>
                                        </div><div class="short-input ue-clear">
                                            <label>接收人：</label>
                                            <input v-model="form.toid" class="form-control" name="toid" required value="" type="text" placeholder="">
                                            <span></span>
                                        </div><div class="short-input ue-clear">
                                            <label>文件地址：</label>
                                            <input v-model="form.filepath" class="form-control" name="filepath" required value="" type="text" placeholder="">
                                            <span></span>
                                        </div><div class="short-input ue-clear">
                                            <label>发送时间：</label>
                                            <input v-model="form.created" class="form-control" name="created" required value="" type="text" placeholder="">
                                            <span></span>
                                        </div>

                                        <input type="hidden" name="id" value="">
                                    </div>
                                    <div class="btn1 ue-clear">
                                        <button @click="submitForm"  type="submit" class="btn btn-primary">提交</button>
                                        
                                    </div> </form>
                            </div>

                           
                        </div>


                    
  </div>
</template>
<script>
import { updateData,getData} from '@/api/chatfileApi'

export default {
  name:'ChatfileEdit',
  data() {
    return {
      form: { fromid:'',toid:'',filepath:'',created:'' },
    }
  },
  created() {
    this.$nextTick(() => {
      this.getData()
    })
  },
  methods: {
    getData(){
      let id = this.$route.params.id;
      getData({id:id}).then(resp=>{
         this.form =  resp.data.data
      })
    },
    submitForm() {
          updateData(this.form).then((resp) => {
            let respData = resp.data //JSON.parse(resp.data);
            if (respData.code == 0) {
              this.$message({
                message: respData.message,
                type: 'error',
              })
            } else {
              this.$message({
                message: respData.message,
                type: 'success',
              })
            }
          })
      }
  },
  beforeDestroy(){
this.removeFile('http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css','css');
this.removeFile( 'http://libs.baidu.com/jquery/2.0.0/jquery.min.js','js');
this.removeFile( 'http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js','js');

  },
  mounted(){
this.loadFile('http://libs.baidu.com/bootstrap1/3.0.3/css/bootstrap1.min.css','css');
this.loadFile( 'http://libs.baidu.com/jquery/2.0.0/jquery.min.js','js');
this.loadFile( 'http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js','js');

  }
}

</script>
<style scoped>

</style>
